﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAO;
using DTO;
using System.Data.SqlClient;
using System.Data;
namespace DAO
{
    public partial class MonAn_DAO
    {
       

        public bool ThemMonAn(MonAn mon_dto)
        {
            DataProvider dp = new DataProvider();
            SqlParameter[] Parameter = new SqlParameter[4];
            Parameter[0] = new SqlParameter("@MaMonAn", mon_dto.MaMonAn);
            Parameter[1] = new SqlParameter("@MaLoaiMonAn", mon_dto.MaLoaiMonAn);
            Parameter[2] = new SqlParameter("@TenMonAn", mon_dto.TenMonAn);
            Parameter[3] = new SqlParameter("@Gia", mon_dto.Gia);
            return dp.ExecutenonQuery("sp_ThemMonAn", Parameter);
        }

        public bool ThemMonAn_NVL(MonAn_NVL monNVL_dto)
        {
            DataProvider dp = new DataProvider();
            SqlParameter[] Parameter = new SqlParameter[3];
            Parameter[0] = new SqlParameter("@MaNVL", monNVL_dto.MaNVL);
            Parameter[1] = new SqlParameter("@MaMonAn", monNVL_dto.MaMonAn);
            Parameter[2] = new SqlParameter("@SoLuong", monNVL_dto.SoLuong);
            return dp.ExecutenonQuery("sp_ThemMonAn_NVL", Parameter);
        }

        public string MaMonTang()
        {
            DataProvider dp = new DataProvider();
            DataTable dt = new DataTable();
            dt = dp.ExecuteQuery("sp_MaMonAn_Tang");
            return dt.Rows[0][0].ToString();
        }

        //public bool SuaLoaiMon(LoaiMonAn loaimon_dto)
        //{
        //    DataProvider dp = new DataProvider();
        //    SqlParameter[] Parameter = new SqlParameter[2];
        //    Parameter[0] = new SqlParameter("@MaLoaiMon", loaimon_dto.MaLoaiMonAn);
        //    Parameter[1] = new SqlParameter("@TenLoaiMon", loaimon_dto.TenLoaiMonAn);
        //    return dp.ExecutenonQuery("sp_SuaLoaiMonAn", Parameter);
        //}

        public bool XoaMon(string MaLoaiMon)
        {
            DataProvider dp = new DataProvider();
            SqlParameter[] Parameter = new SqlParameter[1];
            Parameter[0] = new SqlParameter("@MaMonAn", MaLoaiMon);
            return dp.ExecutenonQuery("sp_XoaMonAn", Parameter);
        }

        public bool XoaMonAn_NVL(string MaNVL)
        {
            DataProvider dp = new DataProvider();
            SqlParameter[] Parameter = new SqlParameter[1];
            Parameter[0] = new SqlParameter("@MaNVL", MaNVL);
            return dp.ExecutenonQuery("sp_XoaMonAn_NVL", Parameter);
        }

        public bool SuaMonAn(MonAn ma_dto)
        {
            DataProvider dp = new DataProvider();
            SqlParameter[] Parameter = new SqlParameter[4];
            Parameter[0] = new SqlParameter("@MaMonAn", ma_dto.MaMonAn);
            Parameter[1] = new SqlParameter("@MaLoaiMonAn", ma_dto.MaLoaiMonAn);
            Parameter[2] = new SqlParameter("@TenMonAn", ma_dto.TenMonAn);
            Parameter[3] = new SqlParameter("@Gia", ma_dto.Gia);
            return dp.ExecutenonQuery("sp_SuaMonAn", Parameter);
        }

        public DataTable DanhSachMonAn()
        {
            DataProvider dp = new DataProvider();
            DataTable dt = new DataTable();
            dt = dp.ExecuteQuery("sp_DanhSachMonAn");
            return dt;
        }

        

        public DataTable DanhSachMon_Ma(string strMa)
        {
            DataProvider dp = new DataProvider();
            DataTable dt = new DataTable();
            SqlParameter[] Parameter = new SqlParameter[1];
            Parameter[0] = new SqlParameter("@MaMonAn", strMa);
            dt = dp.ExecuteQuery("sp_ChiTiet_NVL", Parameter);
            return dt;
        }
    }
}
